package com.luo.ai.mcp.server.config;

import io.modelcontextprotocol.server.McpSyncServerExchange;
import io.modelcontextprotocol.spec.McpSchema;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;
import java.util.function.BiConsumer;

/**
 * Root变更通知配置
 *
 * @author luohq
 * @date 2025-04-27 13:14
 */
@Configuration
public class RootChangeConfig {

    private static final Logger logger = LoggerFactory.getLogger(RootChangeConfig.class);

    /**
     * 注册Root变更通知监听器（MCP Client通知Server）
     *
     * @return Root变更通知监听器
     */
    @Bean
    public BiConsumer<McpSyncServerExchange, List<McpSchema.Root>> rootsChangeHandler() {
        return (exchange, roots) -> {
            logger.info("Registering root resources: {}", roots);
        };
    }
}
